<!DOCTYPE HTML>
<html>

	<head>
		<title>微信sdk</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<link rel="stylesheet" href="/stylesheets/style.css">
	</head>

	<body>
		<div id="app">
			<a href="/saoyisao.apk">android版下载</a><br><br>
			<input type="button" name="" id="refresh" value="刷新页面" /><br><br>
			<input type="button" name="" id="scanQRCode0" value="扫一扫" />
		</div>
		<div>
			<div>
				var signature = '
				<%= signature %>'; var nonceStr = '
				<%= noncestr %>'; var timestamp = '
				<%= timestamp %>'; var appId = '
				<%= appId %>'; var jsapi_ticket = '
				<%= jsapi_ticket%>';
			</div>
			扫描结果：
			<div id="result">

			</div>
		</div>
		<script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var signature = '<%= signature %>';
			var nonceStr = '<%= noncestr %>';
			var timestamp = '<%= timestamp %>';
			var appId = '<%= appId %>';
			var jsapi_ticket = '<%= jsapi_ticket%>';
		</script>
		<script type="text/javascript">
			document.getElementById('refresh').onclick = function() {
				location.reload();
			}

			/**
			 *  以下内容多摘自官方demo
			 *
			 **/
			wx.config({
				debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
				appId: appId, // 必填，公众号的唯一标识
				timestamp: timestamp, // 必填，生成签名的时间戳
				nonceStr: nonceStr, // 必填，生成签名的随机串
				signature: signature, // 必填，签名，见附录1
				jsApiList: ['checkJsApi',
					'onMenuShareTimeline',
					'onMenuShareAppMessage',
					'onMenuShareQQ',
					'onMenuShareWeibo',
					'hideMenuItems',
					'showMenuItems',
					'hideAllNonBaseMenuItem',
					'showAllNonBaseMenuItem',
					'translateVoice',
					'startRecord',
					'stopRecord',
					'onRecordEnd',
					'playVoice',
					'pauseVoice',
					'stopVoice',
					'uploadVoice',
					'downloadVoice',
					'chooseImage',
					'previewImage',
					'uploadImage',
					'downloadImage',
					'getNetworkType',
					'openLocation',
					'getLocation',
					'hideOptionMenu',
					'showOptionMenu',
					'closeWindow',
					'scanQRCode',
					'chooseWXPay',
					'openProductSpecificView',
					'addCard',
					'chooseCard',
					'openCard'
				] // 必填，需要使用的JS接口列表，
			});

			wx.ready(function() {
				// 1 判断当前版本是否支持指定 JS 接口，支持批量判断
				/*document.querySelector('#checkJsApi').onclick = function() {
					wx.checkJsApi({
						jsApiList: [
							'getNetworkType',
							'previewImage',
							"scanQRCode"
						],
						success: function(res) {

						}
					});
				};*/

				// 9 微信原生接口
				// 9.1.1 扫描二维码并返回结果
				document.querySelector('#scanQRCode0').onclick = function() {
					wx.scanQRCode({
						needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
						scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码，默认二者都有
						success: function(res) {
							var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
							var div = document.createElement("div");
							div.innerHTML = JSON.stringify(result);
							document.getElementById("result").appendChild(div);
						}
					});
				};
			});

			wx.error(function(res) {

			});
		</script>
	</body>

</html>